﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MLM.AdminCP.Class;
using Telerik.Web.UI;
using MLM.Base;

namespace MLM.AdminCP.Pages
{
    public partial class TaxMananger : BasePage
    {
        //protected override void OnInit(EventArgs e)
        //{
        //    Permission.CheckIsAdmin();
        //    base.OnInit(e);
        //}
        protected void Page_Load(object sender, EventArgs e)
        {           
            RadGroupTaxsGrid.ItemUpdated += new GridUpdatedEventHandler(radTaxGrid_ItemUpdated);
            RadGroupTaxsGrid.ItemInserted += new GridInsertedEventHandler(radTaxGrid_ItemInserted);
            RadGroupTaxsGrid.ItemDeleted += new GridDeletedEventHandler(radTaxGrid_ItemDeleted);
        }
        void radTaxGrid_ItemDeleted(object sender, GridDeletedEventArgs e)
        {
            if (e.Exception != null)
            {
                e.ExceptionHandled = true;
                Message.ShowError("Tax cannot be deleted. Reason: " + e.Exception.Message);
            }
            else
            {
                Message.ShowSuccess("Tax deleted!");
            }
        }

        void radTaxGrid_ItemInserted(object sender, GridInsertedEventArgs e)
        {
            if (e.Exception != null)
            {
                Message.ShowError("Tax cannot be inserted. Reason: " + e.Exception.Message);
                e.ExceptionHandled = true;
                e.KeepInInsertMode = true;
            }
            else
            {
                Message.ShowSuccess("Tax inserted!");
            }
        }

        void radTaxGrid_ItemUpdated(object sender, GridUpdatedEventArgs e)
        {
            if (e.Exception != null)
            {
                e.KeepInEditMode = true;
                e.ExceptionHandled = true;
                Message.ShowError("Tax cannot be updated. Reason: " + e.Exception.Message);
            }
            else
            {
                Message.ShowSuccess("Tax updated.");
            }
        }    
    }
}